<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/vectrics.tld"    prefix="vectrics" %>



<%@ page import="org.vectrics.hibernate.ThreadProperties" %>
<%@ page import="org.vectrics.domain.Domain" %>
<%@ page import="java.util.Collection" %>
<%@ page import="org.vectrics.recruiter.RecruitServiceLocator" %>
<%@ page import="org.vectrics.cv.Career" %>

<%
	Collection allCareer = null;
	Collection allUniversities = null;
	
	//Recupero las carreras y escuelas / universidades
	allCareer = RecruitServiceLocator.getPersonService().findAllCareer();
	allUniversities = RecruitServiceLocator.getPersonService().findAllUniversity();
	
	//seteo la request de las carreras y universidades. 
	request.setAttribute("allCareer", allCareer);
	request.setAttribute("allUniversities", allUniversities);
	
	String domainId = ThreadProperties.getUriDomainId();
	String userId =request.getParameter("personId");
	String studiesId =request.getParameter("studiesId");
	String formAction ="";
	if ((studiesId!=null) && (!studiesId.trim().equals(""))){
		formAction = "/cv/" + domainId + "/saveStudies.do?personId="+ userId + "&studiesId=" + studiesId;
	} else {
		formAction = "/cv/" + domainId + "/saveStudies.do?personId="+ userId;
	}
%>

<jsp:useBean 	id="studiesEditForm" 
				class="org.vectrics.recruiter.struts.cv.StudiesForm" 
				scope="session"/>

<table width="500">
	<tr>
		<td valign="middle" >
			<html:form action="<%=formAction%>" focus="career" method="POST" >
				<html:hidden property="userId"/>

				<table width="100%">
					<tr>
						<td valign="middle"  width="100%">
							<table width="100%">
								<tr>
									<td valign="top"  width="50%">
										<font class="formLabelClass"><bean:message key="prompt.studies.career" /><b> *</b></font>
									</td>
									<td valign="top" width="50%" >
								       <html:select 
												name="studiesEditForm" 
												property="career" 
												styleClass="formComboClass"
												 >
											  <html:options
											  		collection="allCareer" 
											  		labelProperty="career" 
											  		property="id" />
										</html:select> 
									</td>
								</tr>
								<tr>
									<td valign="top" >
										<font class="formLabelClass"><bean:message key="prompt.studies.school" /><b> *</b></font>
									    <vectrics:errors property="school"/>
									</td>
									<td valign="top" >
										<html:select 
												name="studiesEditForm" 
												property="university" 
												styleClass="formComboClass"
												 >
											  <html:options
											  		collection="allUniversities" 
											  		labelProperty="name" 
											  		property="id" 
											  		/>
										</html:select>
									</td>
								</tr>
								<tr>
									<td  valign="top">
										<font class="formLabelClass"><bean:message key="prompt.studies.status"/><b> *</b></font>
							            <vectrics:errors property="status"/>
									</td>
									<td  valign="top">
										<html:select property="status" styleClass="formComboClass">
											<html:option value="c"><bean:message key="prompt.studies.enCurso"/></html:option>
											<html:option value="f"><bean:message key="prompt.studies.finalizado"/></html:option>
											<html:option value="a"><bean:message key="prompt.studies.abandonado"/></html:option>
										</html:select>
									 </td>
					            </tr>
								<tr>
									<td valign="top">
										<font class="formLabelClass"><bean:message key="prompt.studies.startYear"/><b> *</b></font>
										<vectrics:errors property="startYear"/>
									</td>
									<td  valign="top">
										<html:text property="startYear" styleClass="formEditClass" maxlength="4"/>
									</td>
					            </tr>
					            <tr>
									<td valign="top">
										<font class="formLabelClass"><bean:message key="prompt.studies.endYear"/></font>
										<vectrics:errors property="endYear"/>
									</td>
									<td valign="top">
										<html:text property="endYear" styleClass="formEditClass" maxlength="4"/>
									</td>
								</tr>
								<tr>
									<td valign="top" colspan="2">
										<table>
											<tr>
												<td valign="top"  align="left"></td>
												<td valign="top"  align="left">
													<vectrics:formButton name="submit" code="public.button.ok" phraseCode="button.ok" />
													&nbsp;
													<vectrics:formButton name="cancel" code="public.button.cancel" phraseCode="button.cancel"/>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</html:form>
		</td>
	</tr>
</table>


